<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
<link rel="stylesheet" href="css/style.service.css" />
<script type="text/javascript" src="js/jquery 2.1.1 min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript"
	src="http://webapi.amap.com/maps?v=1.3&key=04b097f9d95b3bfd7fb8a666d7761a7f&plugin=AMap.ToolBar"></script>
<title></title>
</head>
<body style="background: #f2f2f2;">
	<div data-role="page">

		<!--<div data-role="header">
    <h1>欢迎来到我的主页</h1>
  </div>-->

		<div data-role="main" class="ui-content">
			<div id="container"></div>
			<div class="sale_name">销售点名称销售点名称销售点名称销售点名称</div>
			<ul class="detail_addr_box">
				<li><span><img src="img/map1.png" /> </span>详细地址</li>
				<li class="address">
					<p>吉泰路88号香年广场T2吉泰路88号香年广场T吉泰路88号香年广场T2吉泰路88号香年广场T</p>
					<div class="guide">
						<a href="javascript:clickLink();"><img src="img/guide.png" /></a>
					</div>
				</li>
			</ul>
			
			

			<ul class="contact_box">
				<li><span><img src="img/tel1.png" /></span>联系电话</li>
				<li class="tel">
					<p>028 - 8888880</p>
					<div class="tel_box">
						<a href="javascript::"><img src="img/tel.png" /></a>
					</div>
				</li>
			</ul>
			<ul class="service_box">
				<li><span><img src="img/star1.png" /></span>服务评分</li>
				<li class="review"><span class="star"></span><span class="star"></span><span
					class="star"></span><span class="star"></span><span class="star"></span><span
					class="num">5.0</span></li>
			</ul>
		</div>

		<!--<div data-role="footer">
    <h1>底部文本</h1>
  </div>-->

	</div>
</body>
<script>

	function getQueryString(name) {
	   var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
	   var r = window.location.search.substr(1).match(reg);
	   if (r!=null) return (r[2]); return null;
	}
	
	var serviceStationId = getQueryString("serviceStationId");
	
	$(document).ready(function() {
		var liH = $(".address").height();
		var spanH = $(".guide").height();
		var pat = (liH - spanH) / 2 + 8 + "px";
		$(".guide").css("top", pat);

	});
	function loadData(){
		var res = new Object();
		$.ajax({
			url : "/appserver/pub/serviceStationDetail",
			type : "GET",
			async : false,
			data : {
				'serviceStationId' : serviceStationId
			},
			dataType : "json",
			success : function(resData) {

				if(resData.code!="200"){
					alert("网络异常");
					wrapper.refresh();
					return;
				}
				res = resData;
			},
			fail : function() {
				alert("网络异常");
			}
		});
		return res.data;
	}
	
	var data = loadData();

	$(".sale_name").text(data.service_station_name);
	$(".address").children("p").text(data.outlets_addr);
	$(".tel").children("p").text(data.contact_phone);
	$(".tel_box").find("a").attr("href", "tel:"+data.contact_phone);
	
	
	var map = new AMap.Map('container', {
		zoom : 12,
		center : [ data.longitude, data.latitude ]
	});
	var marker = new AMap.Marker({
		position : [ data.longitude, data.latitude ],
		map : map,
	});
	
	function sendCommand(longitude,latitude){  
		
			var u = navigator.userAgent.toLowerCase(); 
			var isAndroid = u.indexOf('android') > -1 || u.indexOf('adr') > -1||u.indexOf('linux') > -1; //android终端
			if(isAndroid){
				// 安卓导航不能使用
				/*  var url="http://apis.map.qq.com/tools/routeplan/eword=终点&epointx="+cmd+"&epointy="+
				 param+"?referer=myapp&key=P44BZ-LANRX-D6I46-ZTXJL-OHJT2-LKBR3"; */
				 var  url="geo:"+longitude+","+latitude+","+data.service_station_name;
				
				window.location.href=url; 
			}else{
				 var url="ios_navigation:"+longitude+":"+latitude;  
			        document.location = url; 
			}
		
        
    } 
  
    function clickLink(){  
        sendCommand(data.longitude,data.latitude);  
    }  
	
</script>
</html>
